s = input()
s = s.split()

sp = ['zero', 'one', 'two', 'three', 'four',
    'five', 'six', 'seven', 'eight', 'nine']
chislo = ''
prost = []
for i in range(100, 1000):
    count_d = 0
    for j in range(2, i // 2 + 1):
        if i % j == 0:
            count_d += 1
    if count_d == 0:
        prost.append(i)
if s[0] in sp and s[1] in sp and s[2] in sp and s[0] != 'zero':
    for i in range(3):
        for j in range(10):
            if s[i] == sp[j]:
                chislo += str(j)
                break
    chislo = int(chislo)
    for i in range(len(prost) - 1):
        if prost[i] <= chislo <= prost[i + 1]:
            if prost[i + 1] - chislo >= chislo - prost[i]:
                print(prost[i])
                break
            else:
                print(prost[i + 1])
                break
        elif chislo == 100:
            print(101)
            break
        elif chislo == 998 or chislo == 999:
            print(997)
            break
else:
    print('Wrong input')